package com.liao.starapp.user;

import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;

import com.liao.starapp.R;

public class FeedbackActivity extends AppCompatActivity implements View.OnClickListener {

    private ImageView img_back;
    private TextView tv_title;
    private EditText et_feedback;
    private Button btn_commit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_feedback);
        initView();
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        getWindow().setStatusBarColor(getColor(R.color.actionBarColor));
    }

    private void initView() {
        img_back = (ImageView) findViewById(R.id.img_back);
        tv_title = (TextView) findViewById(R.id.tv_title);
        et_feedback = (EditText) findViewById(R.id.et_feedback);
        btn_commit = (Button) findViewById(R.id.btn_commit);

        btn_commit.setOnClickListener(this);

        tv_title.setText("反馈建议");
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.btn_commit:
                submit();
                break;
            case R.id.img_back:
                onBackPressed();
                finish();
                break;
        }
    }

    private void submit() {
        // validate
        String feedback = et_feedback.getText().toString();
        if (TextUtils.isEmpty(feedback)) {
            Toast.makeText(this, "您还未输入内容。", Toast.LENGTH_SHORT).show();
            return;
        }
        Toast.makeText(this, "提交成功！", Toast.LENGTH_SHORT).show();
        onBackPressed();
        finish();
    }
}
